function compare(obj1, obj2) {
    if(typeof obj1 !== 'object' || typeof obj2 !== 'object') {
        return obj1 === obj2
    } else {
        let res = true
        Object.keys(obj1).forEach(key => {
            if(!obj2[key]) res = false
            else if(!compare(obj1[key], obj2[key])) res = false
        })
        return res
    }
    
}

let obj1 = {
    name: 'one',
    test: {
        t: 1
    }
}

let obj2 = {
    name: 'one',
    test: {
        t: 12
    }
}

console.log(compare(obj1, obj2))